<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Constructs a new MultipleIterator</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="multipleiterator.attachiterator.html">MultipleIterator::attachIterator</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="multipleiterator.containsiterator.html">MultipleIterator::containsIterator</a></div>
 <div class="up"><a href="class.multipleiterator.html">MultipleIterator</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="multipleiterator.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MultipleIterator::__construct</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0)</p><p class="refpurpose"><span class="refname">MultipleIterator::__construct</span> &mdash; <span class="dc-title">Constructs a new MultipleIterator</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-multipleiterator.construct-description">
  <h3 class="title">说明</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="methodname"><strong>MultipleIterator::__construct()</strong></span>
    ([ <span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$flags</code>
    <span class="initializer"> = MultipleIterator::MIT_NEED_ALL|MultipleIterator::MIT_KEYS_NUMERIC</span>
   </span>
  ] )</div>

  <p class="para rdfs-comment">
   Construct a new MultipleIterator.
  </p>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-multipleiterator.construct-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">flags</code></em></dt>

     <dd>

      <p class="para">
       The flags to set, according to the
       <a href="class.multipleiterator.html#multipleiterator.constants" class="link">Flag Constants</a>.
       <ul class="simplelist">
        <li class="member">
         <strong><code>MultipleIterator::MIT_NEED_ALL</code></strong> or <strong><code>MultipleIterator::MIT_NEED_ANY</code></strong>
        </li>
        <li class="member">
         <strong><code>MultipleIterator::MIT_KEYS_NUMERIC</code></strong> or <strong><code>MultipleIterator::MIT_KEYS_ASSOC</code></strong>
        </li>
       </ul>
      </p>
      <p class="para">       Defaults to <strong><code>MultipleIterator::MIT_NEED_ALL</code></strong>|<strong><code>MultipleIterator::MIT_KEYS_NUMERIC</code></strong>.</p>
     </dd>

    
   </dl>

  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-multipleiterator.construct-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   没有返回值。
  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-multipleiterator.construct-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="multipleiterator.example.basic">
    <p><strong>Example #1 Iterating a MultipleIterator</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$people&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">ArrayIterator</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'John'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Jane'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Jack'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Judy'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$roles&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">ArrayIterator</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'Developer'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Scrum&nbsp;Master'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Project&nbsp;Owner'</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$team&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MultipleIterator</span><span style="color: #007700">(</span><span style="color: #0000BB">$flags</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$team</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">attachIterator</span><span style="color: #007700">(</span><span style="color: #0000BB">$people</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'person'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$team</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">attachIterator</span><span style="color: #007700">(</span><span style="color: #0000BB">$roles</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'role'</span><span style="color: #007700">);<br /><br />foreach&nbsp;(</span><span style="color: #0000BB">$team&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$member</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$member</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>
 
    <div class="example-contents"><p>Output with <em>$flags = MIT_NEED_ALL|MIT_KEYS_NUMERIC</em></p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [0] =&gt; John
    [1] =&gt; Developer
)
Array
(
    [0] =&gt; Jane
    [1] =&gt; Scrum Master
)
Array
(
    [0] =&gt; Jack
    [1] =&gt; Project Owner
)</pre></div>
    </div>
    <div class="example-contents"><p>Output with <em>$flags = MIT_NEED_ANY|MIT_KEYS_NUMERIC</em></p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [0] =&gt; John
    [1] =&gt; Developer
)
Array
(
    [0] =&gt; Jane
    [1] =&gt; Scrum Master
)
Array
(
    [0] =&gt; Jack
    [1] =&gt; Project Owner
)
Array
(
    [0] =&gt; Judy
    [1] =&gt;
)</pre></div>
    </div>
    <div class="example-contents"><p>Output with <em>$flags = MIT_NEED_ALL|MIT_KEYS_ASSOC</em></p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [person] =&gt; John
    [role] =&gt; Developer
)
Array
(
    [person] =&gt; Jane
    [role] =&gt; Scrum Master
)
Array
(
    [person] =&gt; Jack
    [role] =&gt; Project Owner
)</pre></div>
    </div>
    <div class="example-contents"><p>Output with <em>$flags = MIT_NEED_ANY|MIT_KEYS_ASSOC</em></p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [person] =&gt; John
    [role] =&gt; Developer
)
Array
(
    [person] =&gt; Jane
    [role] =&gt; Scrum Master
)
Array
(
    [person] =&gt; Jack
    [role] =&gt; Project Owner
)
Array
(
    [person] =&gt; Judy
    [role] =&gt;
)</pre></div>
    </div>    
   </div>
  </p>
 </div>
   

 <div class="refsect1 seealso" id="refsect1-multipleiterator.construct-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><a href="class.multipleiterator.html#multipleiterator.constants" class="link">Flag Constants</a></li>
    <li class="member"><span class="methodname"><a href="multipleiterator.valid.html" class="methodname" rel="rdfs-seeAlso">MultipleIterator::valid()</a> - Checks the validity of sub iterators</span></li>
   </ul>
  </p>
 </div>

 
</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="multipleiterator.attachiterator.html">MultipleIterator::attachIterator</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="multipleiterator.containsiterator.html">MultipleIterator::containsIterator</a></div>
 <div class="up"><a href="class.multipleiterator.html">MultipleIterator</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
